package dto

import (
	"tuowei.com/app/admin/models"
	"tuowei.com/common/dto"
	common "tuowei.com/common/models"
)

type SysCourseWareInsertReq struct {
	Id       int    `json:"id"`
	CourseId int    `json:"course_id" comment:"课程ID" vd:"$>0; msg:'课程ID为空'"`
	Name     string `json:"name" comment:"子章节名称" vd:"@:len($)>0; msg:'子章节名称不能为空'"`
	Url      string `json:"url" comment:"子章节课件url地址"`
	Sort     int    `json:"sort" comment:"排序"`
	Pid      int    `json:"pid" comment:"父级ID"`
	IsShow   int    `json:"is_show" comment:"是否显示"`
	UrlName  string `json:"url_name" comment:"课件名称"`
	common.ControlBy
}

func (s *SysCourseWareInsertReq) Generate(model *models.SysCourseWare) {
	model.Id = s.Id
	model.Name = s.Name
	model.Sort = s.Sort
	model.CourseWare = s.Url
	model.CourseId = s.CourseId
	model.Pid = s.Pid
	if s.Pid == 0 {
		model.Level = 1
		model.CourseWare = "111"
	} else {
		model.Level = 2
	}
	model.IsShow = s.IsShow
	model.UrlName = s.UrlName
	model.CreateBy = s.CreateBy
	model.Creator = s.Creator
}

func (s *SysCourseWareInsertReq) GetId() interface{} {
	return s.Id
}

type SysCourseWareChangeReq struct {
	CourseWareId int    `json:"course_ware_id" comment:"课程章节ID" vd:"$>0; msg:'课程章节ID不能为空'"`
	Url          string `json:"url" comment:"课件url地址" vd:"@:len($)>0; msg:'课件链接地址不能为空'"`
	common.ControlBy
}

func (e SysCourseWareChangeReq) Generate(model *models.SysCourseWare) {

	model.Id = e.CourseWareId
	model.CourseWare = e.Url
}

func (e SysCourseWareChangeReq) GetId() int {
	return e.CourseWareId
}

type SysCourseWareById struct {
	dto.ObjectById
	common.ControlBy
}

type SysCourseWareDeleteByIdReq struct {
	dto.ObjectById
	common.ControlBy
	LinkId int `json:"link_id"`
}

type SysCourseWareDeleteLargeChapterByIdReq struct {
	dto.ObjectById
	common.ControlBy
}

type SysCourseWareUpdateReq struct {
	Id       int    `json:"id" vd:"$>0; msg:'课件ID不能为空'"`
	CourseId int    `json:"course_id" comment:"课程ID" vd:"$>0; msg:'课程ID不能为空'"`     // 课程ID
	Name     string `json:"name" comment:"子章节名称" vd:"@:len($)>0; msg:'子章节名称不能为空'"` // 子章节名称
	Url      string `json:"url" comment:"课件地址"`                                    // 课件地址
	Pid      int    `json:"pid"`
	IsShow   int    `json:"is_show" comment:"是否显示"`
	Sort     int    `json:"sort"`
	UrlName  string `json:"url_name" comment:"课件名称"`
	common.ControlBy
}

func (s *SysCourseWareUpdateReq) Generate(model *models.SysCourseWare) {
	if s.Id != 0 {
		model.Id = s.Id
	}
	model.Name = s.Name
	model.CourseWare = s.Url
	model.CourseId = s.CourseId
	model.Pid = s.Pid
	model.Sort = s.Sort
	model.IsShow = s.IsShow
	model.UrlName = s.UrlName
	model.UpdateBy = s.UpdateBy
	model.Updater = s.Updater
	if s.Pid == 0 {
		model.Level = 1
		model.CourseWare = "1111"
	} else {
		model.Level = 2
	}

}

func (s *SysCourseWareUpdateReq) GetId() interface{} {
	return s.Id
}
